package edu.scau.cxq.gp.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import edu.scau.cxq.gp.entity.Inventory;
import edu.scau.cxq.gp.mapper.InventoryMapper;
import edu.scau.cxq.gp.service.IInventoryService;
import edu.scau.cxq.gp.entity.vo.InventoryVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @description 库存 服务实现类
 * @return
 * @author TLC
 */

@Service
public class InventoryServiceImpl extends ServiceImpl<InventoryMapper, Inventory> implements IInventoryService {


    @Resource
    private InventoryMapper inventoryMapper;

    /**
     * 获取分页库存对象
     * @param currentPage
     * @param size
     * @param goodsId
     * @param wareId
     * @return
     */
    @Override
    public PageInfo<InventoryVO> getInventoryVOList(Integer currentPage, Integer size, Long goodsId, Long wareId) {
        PageHelper.startPage(currentPage, size);
        List<InventoryVO> inventoryVOs = inventoryMapper.selectInventoryVOList(goodsId, wareId);
        PageInfo<InventoryVO> recordOutVOPageInfo = new PageInfo<>(inventoryVOs);
        return recordOutVOPageInfo;
    }

    /**
     * 库存整理
     */
    @Override
    public void sortInventory() {

        inventoryMapper.sortInventory();
    }
}
